import { callEndpoint, type ApiEndpoint as RestApiEndpoint, } from '@wp-typia/rest'; import { type {{pascalCase}}BootstrapQuery, type {{pascalCase}}StateQuery, type {{pascalCase}}WriteStateRequest, } from './api-types'; import { get{{pascalCase}}BootstrapEndpoint, get{{pascalCase}}StateEndpoint, write{{pascalCase}}StateEndpoint, } from './api-client'; import { resolveTransportCallOptions, type PersistenceTransportOptions, } from './transport'; function createRestEndpoint(endpoint: { method: RestApiEndpoint['method']; path: string; validateRequest: RestApiEndpoint['validateRequest']; validateResponse: RestApiEndpoint['validateResponse']; }): RestApiEndpoint { // Strip generator-only helper fields so the runtime client only sees the // canonical RestApiEndpoint surface it expects. return { method: endpoint.method, path: endpoint.path, validateRequest: endpoint.validateRequest, validateResponse: endpoint.validateResponse, }; } {{bootstrapEndpointDeclaration}} {{stateEndpointDeclaration}} {{writeStateEndpointDeclaration}} export function fetchState( request: {{pascalCase}}StateQuery, options: PersistenceTransportOptions = {}, ) { return callEndpoint( stateEndpoint, request, resolveTransportCallOptions( options.transportTarget ?? 'frontend', 'read', stateEndpoint, request, options, ), ); } export function fetchBootstrap( request: {{pascalCase}}BootstrapQuery, options: PersistenceTransportOptions = {}, ) { return callEndpoint( bootstrapEndpoint, request, resolveTransportCallOptions( options.transportTarget ?? 'frontend', 'read', bootstrapEndpoint, request, options, ), ); } export function writeState( request: {{pascalCase}}WriteStateRequest, options: PersistenceTransportOptions = {}, ) { return callEndpoint( writeStateEndpoint, request, resolveTransportCallOptions( options.transportTarget ?? 'frontend', 'write', writeStateEndpoint, request, options, ), ); }